import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-11-22
 * Time:16:05
 */
public class Test {
    class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        public TreeNode(int val){
            this.val=val;
        }
    }
    public TreeNode buildTree(int[] preorder, int[] inorder) {
        int end=inorder.length-1;
        TreeNode root =buildTreeChild(preorder,inorder,0,end);
        return root;
    }
    public int find(int []inorder,int begin,int end,int cur){
        for(int i=begin;i<=end;i++){
            if(inorder[i]==cur){
                return i;
            }
        }
        return -1;
    }
    int now=0;
    public TreeNode buildTreeChild(int[] preorder,int []inorder,int begin, int end){
        if(begin>end){
            return null;
        }
        TreeNode root=new TreeNode(preorder[now]);
        int mid=find(inorder,begin,end,root.val);
        if(mid==-1){
            return null;
        }
        now++;
        root.left=buildTreeChild(preorder,inorder,begin,mid-1);
        root.right=buildTreeChild(preorder,inorder,mid+1,end);
        return root;
    }
    public String tree2str(TreeNode root) {

        StringBuffer stringbuffer=new StringBuffer();
        if(root==null){
            return stringbuffer.toString();
        }
        child(stringbuffer,root);
        return stringbuffer.toString();
    }
    public void child(StringBuffer stringbuffer,TreeNode root){
        if(root==null){
            return;
        }
        stringbuffer.append(root.val);
        if(root.left!=null||root.right!=null){
            stringbuffer.append('(');
            child(stringbuffer,root.left);
            stringbuffer.append(')');
        }
        if(root.right!=null){
            stringbuffer.append('(');
            child(stringbuffer,root.right);
            stringbuffer.append(')');
        }
    }
    public boolean isBalanced(TreeNode root) {
        if(root==null){
            return true;
        }
        int right=height(root.right);
        int left=height(root.left);
        int max=right>left?right:left;
        int min=right>left?left:right;
        if(max-min<2){
            return isBalanced(root.left)&&isBalanced(root.right);
        }else{
            return false;
        }
    }
    public int height(TreeNode root){
        if(root==null){
            return 0;
        }
        int right=height(root.right);
        int left=height(root.left);
        return right>left?right+1:left+1;
    }
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null&&q==null){
            return true;
        }
        if(p!=null&&q!=null){
            if(p.val==q.val){
                return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);
            }else{
                return false;
            }
        }
        return false;
    }
    class Solution {
        public TreeNode invertTree(TreeNode root) {
            if(root==null){
                return root;
            }
            invertTreeChild(root);
            return root;
        }
        public void invertTreeChild(TreeNode root){
            if(root==null){
                return ;
            }
            TreeNode cur=root.left;
            root.left=root.right;
            root.right=cur;
            invertTreeChild(root.left);
            invertTreeChild(root.right);
        }
    }

    public static void main(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.createTree();
        //binaryTree.preOrder(root);
        //binaryTree.inOrder(root);
        //System.out.println(binaryTree.size2(root));
        //binaryTree.getLeafNodeCount1(root);
        //System.out.println(BinaryTree.leafSize);
        //System.out.println(binaryTree.getLeafNodeCount2(root));
        //System.out.println(binaryTree.getKLevelNodeCount(root, 4));
        //System.out.println(binaryTree.getHeight(root));
        //System.out.println(binaryTree.find(root, 'c').val);
       // binaryTree.levelOrder(root);
        System.out.println(binaryTree.isCompleteTree(root));
    }
    public static void main5(String []args){
        Scanner scanner=new Scanner(System.in);
        String str=scanner.nextLine();
        int i=0;
        main1(str,i);
        System.out.println();
    }
    public static void main1(String str,int i){
        if(i>str.length()){
            return;
        }
        StringBuffer string=new StringBuffer();
        while(i<str.length()&&str.charAt(i)!=' '){
            string.append(str.charAt(i));
             i++;
        }

        i++;
        main1(str,i);
         System.out.print(string.toString()+" ");
    }
}
